/*
 * ==========================================================================*\
 * | $Id$
 * |*-------------------------------------------------------------------------*|
 * | Copyright (C) 2009 Virginia Tech | | This file is part of CloudSpace. | |
 * CloudSpace is free software; you can redistribute it and/or modify | it under
 * the terms of the GNU General Public License as published | by the Free
 * Software Foundation; either version 3 of the License, or | (at your option)
 * any later version. | | CloudSpace is distributed in the hope that it will be
 * useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of |
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | GNU General
 * Public License for more details. | | You should have received a copy of the
 * GNU General Public License | along with CloudSpace; if not, see
 * <http://www.gnu.org/licenses/>.
 * \*==========================================================================
 */

package cloudspace.controlpanel.promote;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericComposer;
import org.zkoss.zul.Window;
import org.zkoss.zul.api.Textbox;

import cloudspace.demoitem.DemoItemsController;

/**
 * The controller for the Promote page related to demo items.
 * 
 * @author Sunil Kamalakar
 */
public class PromotePageController extends GenericComposer {
	

	private static final long serialVersionUID = 8535754978004437210L;

	//Binding the URI elements
	private Window promoteWindow;
	private Textbox programURI, tooltip;
	
	@Override
    public void doAfterCompose( Component component ) throws Exception
    {
		 super.doAfterCompose(component);
		 promoteWindow = (Window)component.getFellow("promoteWindow");
		 programURI = (Textbox)component.getFellow("programURI");
		 tooltip = (Textbox)component.getFellow("tooltip"); 
    }
	
    public void onOK(Event event) throws Exception
    {
    	DemoItemsController demoController = new DemoItemsController();
    	  	
		demoController.addDemoItem(programURI.getValue(), null, tooltip.getValue(), true);	
		promoteWindow.detach();
    }
}
